import { Injectable } from '@angular/core'
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { HttpClient, HttpHeaders } from '@angular/common/http'
import { catchError, map, tap } from 'rxjs/operators';

import { Config } from '../config'
import { SignInModel } from './signin/signin.model';

@Injectable()
export class AccountService {
  constructor(private http: HttpClient, private config: Config) {

  }

  signIn(model: any): Observable<Object> {
    return this.http.post(this.config.api+'account/login', model)
      .pipe(
        tap(data => console.log(data)),
        catchError((err, result) => {
          console.log(err);
          return of(result);
        })
      );
  }
}
